'This module was inspired by the VISUAL BASIC WORKSHOP column in the May 1994
'issue of Britain's PC PLUS magazine (pg 296), which introduced me to the joys
'of the BitBlt API call.
'
'To use the Dice, place the dice bitmap (dice.bmp) in a PictureBox on the
'form. You can hide it by pulling the side of the form over it (see
'Roller1.FRM) in the example. Place more PictureBoxes on the form, one for
'each of the die you want to show.
'
'Display the dice by calling the following subroutine:
'
'ShowDie (Source, Target, Digit, Color)
'
' where Source is the PictureBox containing the Dice Bitmap (dice.bmp)
' Target is the PictureBox that will contain the displayed die
' Digit is an integer between 1 and 6 referring to the die face
' Color is an integer between 1 and 3 referring to the die color
'
'
'To use the Numbers, place the Number bitmap (Num.bmp) in a PictureBox on
'the form. You can hide it by pulling the side of the form over it (see
'Roller1.FRM) in the example. place more PictureBoxes on the form, one for
'each Digit you want to show.
'
'Display the numbers by calling the following subroutine:
'
'ShowNum (Source, Target, Digit, Color)
'
' where Source is the PictureBox containing the Number Bitmap (num.bmp)
' Target is the PictureBox that will contain the displayed digit
' Digit is an integer between 0 and 9 referring to the value
' Color is an integer between 1 and 3 referring to the color
'
'
' Note: Make sure you set the AUTOREDRAW property of the hidden
' PictureBox(es) to TRUE or the graphics repaints won't work correctly.
'
Option Explicit
'Declare API call BitBlt
Global Const SRCCOPY = &HCC0020
Declare Function BitBlt Lib "GDI" (ByVal hDestDC As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As Integer, ByVal XSrc As Integer, ByVal YSrc As Integer, ByVal dwRop As Long) As Integer
Global res As Integer 'Holder for Funtion BitBlt result
Sub Method1(A As Integer, B As Integer, C As Integer)
'
'Rolls a set of 5 dice by randomly determining the result and
'calling Sub ShowDie
'
Randomize 'get a random number between 1 and 6 for each
A = Int(6 * Rnd + 1) 'die
Randomize
B = Int(6 * Rnd + 1)
Randomize
C = Int(6 * Rnd + 1)
Return
End Sub
Sub ShowDie(Source As PictureBox, Target As PictureBox, Digit As Integer, Color As Integer)
'
'this subroutine clips a die face from the bitmap in SOURCE and
'puts it in TARGET
'PLEASE note that these two Parameters are reversed from Sub ShowNum because
'the two SOURCE bitmaps are oriented differently. That is, the dice bitmap
'is set up with the colors accross the top and the numbers down and the